package com.yq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yq.domain.DictData;
import com.yq.mapper.DictDataMapper;
import com.yq.servicce.DictDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
/**
* @Author: yangQ
* @Date: 2020/11/24 19:56
* @Description:
*/
@Service
public class DictDataServiceImpl implements DictDataService{

    @Autowired
    DictDataMapper dictDataMapper;

    /**
     * 根据字典类型查询字典数据
     * @param dictType
     * @return
     */
    @Override
    public List<DictData> selectDictDataByDictType(String dictType) {
        QueryWrapper<DictData> qw=new QueryWrapper<>();
        if(StringUtils.isBlank(dictType)){
            //如果dictType为空或不存在，那么不能返回所有字典数据给用户，只能返回一个空集合
            return Collections.EMPTY_LIST;
        }
        qw.eq(DictData.COL_DICT_TYPE,dictType);
        return this.dictDataMapper.selectList(qw);
    }
}
